package pri.syl.xiaowu.websocket.netty.server.thread.execution;


import pri.syl.xiaowu.websocket.core.exception.WebsocketException;
import pri.syl.xiaowu.websocket.core.template.WebsocketChannelTemplate;
import pri.syl.xiaowu.websocket.core.template.WebsocketRouteTemplate;
import pri.syl.xiaowu.websocket.netty.server.thread.AbstractWebsocketServerTimeoutThread;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:25
 * @Description 连接超时执行器
 **/
public class WebsocketServerTimeoutThreadExecution extends AbstractWebsocketServerTimeoutThread {
    public WebsocketServerTimeoutThreadExecution(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate) {
        super(websocketRouteTemplate, websocketChannelTemplate);
    }

    @Override
    protected void timeout(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate) {
        try {
            websocketRouteTemplate.connectionTimeoutEvent(websocketChannelTemplate);
        } catch (Exception e) {
            websocketRouteTemplate.errorEvent(websocketChannelTemplate, new WebsocketException(e));
        }
    }
}
